#Rem
Header: console class 
#End

Strict
Import mojo
Import agfx

#Rem
summary: TConsole
#End
Class TConsole

	#Rem
		summary: list of lines 
	#End
	Field lines:StringList
	
	#Rem
		summary: used font
		[i]private[/i]
	#End
	Field fnt:TFont
	
	#Rem
		summary: enable state
	#End
	Field enable:Bool
	
	#Rem
		summary: constructor
	#End
	Method New()
		Self.lines = New StringList
		FONTS.Load("smallfont")	
		Self.fnt = FONTS.Find("smallfont")
		Self.enable=False
	End Method
	
	#Rem
		summary: add line to console
	#End
	Method Add:Void(l:String)
		
		Self.lines.AddLast(l)
		If lines.Count()=15 Then 
			Self.lines.RemoveFirst()
		EndIf
		
	End Method

	#Rem
		summary: draw console
		add this call to OnRender() app callback
	#End	
	Method Draw:Void()
	
		If Self.enable Then
			
			Local i:Int = 0
			Local s:String

			SetColor (128,128,128)
			SetAlpha(0.5)
			DrawRect(0,0,DISPLAY.VSCREEN_WIDTH,132)
			SetAlpha(1)
			SetColor (255,255,0)
			For s = eachin Self.lines
				Self.fnt.DrawText(s,24,i*9,0)
				i+=1
			Next
			
		EndIf
		
	End Method
	
	#Rem
		summary: show console
	#End
	Method Show:Void()
		Self.enable = True
	End Method
	
	#Rem
		summary: hide console
	#End
	Method Hide:Void()
		Self.enable = False
	End Method
	
End Class

